package com.hmall.user.web;

import com.hmall.user.pojo.Address;
import com.hmall.user.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

@RequestMapping("/address")
@RestController
public class AddressController {

    @Autowired(required = false)
    private AddressService addressService;

    //根据用户id查询地址列表
    @GetMapping("/uid/{userId}")
    private List<Address> listUid(@PathVariable Long userId){
        List<Address> addressList=addressService.getById(userId);
        return addressList;
    }
    //根据addressID查询地址
    @GetMapping("/{addressId}")
    public Address listAddressId(@PathVariable Long addressId){
        Address address=addressService.getByAddressId(addressId);
        return address;
    }
}
